<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>运行状态</title>
  <link href="./css/index.css" rel="stylesheet">
  <style>
    body,
    * {
      padding: 0;
      margin: 0;
    }
  </style>
</head>

<body>
  <div class="page-container" id="page-container">
  </div>
</body>
<script src="./js/vue3.js"></script>
<script src="./config.js"></script>
<script src="../../js/api/secondEdition.js"></script>
<script src="../../js/method.js"></script>


<script>
  const { createApp, ref, nextTick, reactive, onMounted, onUnmounted, watch, computed } = Vue
  const app = createApp({
    setup() {

      // 处理模拟数据
      const apiPreFix = computed(() => {
        return isMock ? '' : apiUrl
      })

      // 处理模拟数据
      const api = computed(() => {
        return isMock ? mockApi : realApi
      })

      // 获取字典的数据存入缓存，作为全局使用的公用数据
      const getInitData = () => {
        fetch(apiPreFix.value + api.value.getDicts)
          .then(res => res.json())
          .then(res => {
            res.subMsg = []
            res.areas.forEach((item, index) => {
              res.subMsg.push({subId: item.master, siteList: []})
              item.slave.forEach(ele => {
                res.subMsg[index].siteList.push({
                  siteId: ele
                })
              })
            })
            window.sessionStorage.setItem('BASE_DICTS', JSON.stringify(res))
          }).finally(() => {
            const currentPage = JSON.parse(window.sessionStorage.getItem('CURRENT_PAGE'))
            changeTab(currentPage ?? pageTab[0])
          })
      }

      onMounted(() => {
        getInitData()
      })

      return {
      }
    },
  })
  app.mount("#page-container");
</script>

</html>